<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script src="../jquery-3.3.1.min.js"></script>
    <style type="text/css">
        #box{
            width: 800px;
            height: 200px;
            border: 3px solid #999;
            margin: 20px auto;
            overflow: scroll;
        }
        #content{
            width: 10000px;
        }
        #imglist{
            float: left;
        }
        #imglist img{
            width: 300px;
            height: 200px;
            float: left;
        }
    </style>
</head>
<body>
    
    <div id="box">
        <div id="content">
            <div id="imglist">
                <img src="../imgs/1.jpg">
                <img src="../imgs/2.jpg">
                <img src="../imgs/3.jpg">
                <img src="../imgs/4.jpg">
                <img src="../imgs/5.jpg">
            </div>
        </div>
    </div>
    <script>
        $(function(){
            // 获取一轮图片的宽度
            var width = $('#imglist').innerWidth();

            // 克隆到当前图后
            $('#imglist').clone().appendTo('#content');
            function play(){
                if ($('#box').scrollLeft() >= width) {
                    $('#box').scrollLeft(0);
                }
                $('#box').scrollLeft($('#box').scrollLeft()+1);
            }
            setInterval(play,1)
        })
    </script>
</body>
</html>